
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.JLabel;
import javax.swing.JPanel;

public class ProgressBar extends JPanel{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	static Color borderColor = new Color(0.6f, 0.7f, 0.7f, 1.0f);
	static Color progressColor = new Color(0.7f, 0.7f, 0.7f, 1.0f);
	static int borderTickness = 1;
	
	Dimension panelSize; 
	float prograss = 0;
	JLabel rep; 
		
	
	ProgressBar(Dimension d) {
		super();
		
		panelSize = d;
		
		//rep = new JLabel("0/100"); 
		//this.add(rep);
		
		
		this.setPreferredSize(d);
		//this.setBorder(new LineBorder(borderColor, borderTickness));		
		}	
	
	public synchronized void paintComponent(Graphics g) {
		//super.paintComponent(g);
		
		g.setColor(progressColor);		
		g.fillRect(1, 1, (int)(this.getWidth()*prograss)-2 , this.getHeight()-2);
		if (prograss>0) {
			g.setColor(borderColor);			
			g.drawRect(0, 0, panelSize.width-1, panelSize.height-1);
			}
		//this.revalidate();
		}
	public synchronized void redraw() {
		this.paintComponent(this.getGraphics());
		}
	
	public void setProgress(float progre) {
		this.prograss = progre;
		//int iProg = (int)(progre*100);
			
		//rep.setText(iProg + "/100");
		this.redraw();
		
		}
}
